﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace EventLogAnalyzer.ViewModel
{
    public class LogFilesViewModel : ViewModelBase
    {
        public LogFilesViewModel()
        {
            LogFileViewModels = new ObservableCollection<LogFileViewModel>();    
        }

        public ObservableCollection<LogFileViewModel> LogFileViewModels { get; set; }

        public void ShowLogs(IEnumerable<EventLogViewModel> logs)
        {
            LogFileViewModels.ToList().ForEach(f => f.VisibleLogsCount = 0);
            LogFileViewModels.ToList().ForEach(f => f.Logs.ToList().ForEach(l =>
                                                                            {
                                                                                if (logs.Contains(l) && f.VisibleLogsCount < 15)
                                                                                {
                                                                                    l.IsToBeShown = true;
                                                                                    f.VisibleLogsCount++;
                                                                                }
                                                                                else
                                                                                    l.IsToBeShown = false;
                                                                            }));
        }
    }
}